From d9c92598612714683eab96fecf6e90a9531607e5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 21 Sep 2010 16:35:17 +0200 Subject: [PATCH] Move GtkSizeRequest into GtkWidget It doesn't make sense to keep them separate as GtkSizeRequest requires a GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have one without the other. It also makes the code a lot easier because no casts are required when calling functions. Also, the names would translate to gtk_widget_get_width() and people agreed that this would be a too generic name, so a "preferred" was added to the names. So this patch moves the functions: gtk_size_request_get_request_mode() => gtk_widget_get_request_mode() gtk_size_request_get_width() => gtk_widget_get_preferred_width() gtk_size_request_get_height() => gtk_widget_get_preferred_height() gtk_size_request_get_size() => gtk_widget_get_preferred_size() gtk_size_request_get_width_for_height() => gtk_widget_get_preferred_width_for_height() gtk_size_request_get_height_for_width() => gtk_widget_get_preferred_height_for_width() ... and moves the corresponding vfuncs to the GtkWidgetClass. The patch also renames the implementations of the vfuncs in widgets to include the word "preferrred". --- demos/gtk-demo/offscreen_window.c | 6 +- demos/gtk-demo/offscreen_window2.c | 6 +- demos/testpixbuf-scale.c | 2 +- docs/reference/gtk/gtk3-sections.txt | 16 +- docs/reference/gtk/gtk3.types | 1 - docs/reference/gtk/tmpl/gtkcontainer.sgml | 2 +- .../gtk/tmpl/gtkfilechooserbutton.sgml | 2 +- gtk/gtk.symbols | 13 +- gtk/gtkaccellabel.c | 32 +-- gtk/gtkalignment.c | 79 ++++---- gtk/gtkarrow.c | 38 ++-- gtk/gtkaspectframe.c | 3 +- gtk/gtkassistant.c | 32 +-- gtk/gtkbbox.c | 7 +- gtk/gtkbin.c | 103 +++++----- gtk/gtkbox.c | 150 +++++++------- gtk/gtkbutton.c | 38 ++-- gtk/gtkcellrendereraccel.c | 3 +- gtk/gtkcellrenderertext.c | 3 +- gtk/gtkcellview.c | 86 ++++---- gtk/gtkcheckbutton.c | 7 +- gtk/gtkcolorsel.c | 4 +- gtk/gtkcombobox.c | 134 ++++++------- gtk/gtkcontainer.c | 4 +- gtk/gtkentry.c | 11 +- gtk/gtkentrycompletion.c | 8 +- gtk/gtkeventbox.c | 3 +- gtk/gtkexpander.c | 117 ++++++----- gtk/gtkfilechooserdefault.c | 16 +- gtk/gtkfilechooserdialog.c | 8 +- gtk/gtkfilechooserentry.c | 4 +- gtk/gtkfixed.c | 11 +- gtk/gtkfontsel.c | 6 +- gtk/gtkframe.c | 109 +++++------ gtk/gtkhandlebox.c | 12 +- gtk/gtkiconview.c | 4 +- gtk/gtkimagemenuitem.c | 10 +- gtk/gtklabel.c | 103 +++++----- gtk/gtklayout.c | 8 +- gtk/gtklinkbutton.c | 3 +- gtk/gtkmenu.c | 84 ++++---- gtk/gtkmenubar.c | 9 +- gtk/gtkmenuitem.c | 71 +++---- gtk/gtkmenutoolbutton.c | 8 +- gtk/gtknotebook.c | 28 ++- gtk/gtkoffscreenwindow.c | 6 +- gtk/gtkpaned.c | 15 +- gtk/gtkpathbar.c | 29 ++- gtk/gtkprintoperation-win32.c | 4 +- gtk/gtkprivate.h | 2 +- gtk/gtkrecentchooserdefault.c | 7 +- gtk/gtkscrolledwindow.c | 107 +++++----- gtk/gtksizegroup.c | 7 +- gtk/gtksizerequest.c | 154 +++++++-------- gtk/gtksizerequest.h | 59 +----- gtk/gtksocket.c | 3 +- gtk/gtkspinbutton.c | 15 +- gtk/gtkspinner.c | 35 ++-- gtk/gtkstatusicon.c | 4 +- gtk/gtktable.c | 19 +- gtk/gtktextlayout.c | 3 +- gtk/gtktextview.c | 23 +-- gtk/gtktoolbar.c | 25 ++- gtk/gtktoolitem.c | 3 +- gtk/gtktoolitemgroup.c | 36 ++-- gtk/gtktoolpalette.c | 4 +- gtk/gtktooltip.c | 4 +- gtk/gtktreeview.c | 30 ++- gtk/gtkviewport.c | 75 ++++--- gtk/gtkwidget.c | 78 ++++---- gtk/gtkwidget.h | 38 ++++ gtk/gtkwin32embedwidget.c | 3 +- gtk/gtkwindow.c | 57 +++--- gtk/gtkwrapbox.c | 183 +++++++++--------- modules/input/gtkimcontextxim.c | 2 +- tests/gtkoffscreenbox.c | 12 +- tests/testellipsise.c | 3 +- tests/testgtk.c | 2 +- 78 files changed, 1092 insertions(+), 1359 deletions(-) diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c index 96fd8d4031..410f524d12 100644 --- a/demos/gtk-demo/offscreen_window.c +++ b/demos/gtk-demo/offscreen_window.c @@ -391,7 +391,7 @@ gtk_rotated_bin_size_request (GtkWidget *widget, child_requisition.height = 0; if (bin->child && gtk_widget_get_visible (bin->child)) - gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child), + gtk_widget_get_preferred_size ( (bin->child), &child_requisition, NULL); s = sin (bin->angle); @@ -434,8 +434,8 @@ gtk_rotated_bin_size_allocate (GtkWidget *widget, s = sin (bin->angle); c = cos (bin->angle); - gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child), - &child_requisition, NULL); + gtk_widget_get_preferred_size (bin->child, + &child_requisition, NULL); child_allocation.x = 0; child_allocation.y = 0; child_allocation.height = child_requisition.height; diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c index b623e303ef..c03d8c0c38 100644 --- a/demos/gtk-demo/offscreen_window2.c +++ b/demos/gtk-demo/offscreen_window2.c @@ -315,7 +315,7 @@ gtk_mirror_bin_size_request (GtkWidget *widget, child_requisition.height = 0; if (bin->child && gtk_widget_get_visible (bin->child)) - gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child), + gtk_widget_get_preferred_size ( (bin->child), &child_requisition, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); @@ -349,8 +349,8 @@ gtk_mirror_bin_size_allocate (GtkWidget *widget, GtkRequisition child_requisition; GtkAllocation child_allocation; - gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child), - &child_requisition, NULL); + gtk_widget_get_preferred_size (bin->child, + &child_requisition, NULL); child_allocation.x = 0; child_allocation.y = 0; child_allocation.height = child_requisition.height; diff --git a/demos/testpixbuf-scale.c b/demos/testpixbuf-scale.c index 85134c8bbb..8051fa5edd 100644 --- a/demos/testpixbuf-scale.c +++ b/demos/testpixbuf-scale.c @@ -135,7 +135,7 @@ main(int argc, char **argv) gtk_widget_show_all (vbox); /* Compute the size without the drawing area, so we know how big to make the default size */ - gtk_size_request_get_size (GTK_SIZE_REQUEST (vbox), + gtk_widget_get_preferred_size ( (vbox), &scratch_requisition, NULL); darea = gtk_drawing_area_new (); diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 8bec4d121b..53b869b773 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -6290,16 +6290,14 @@ gtk_orientable_get_type
gtksizerequest GtkSizeRequest -GtkSizeRequest -GtkSizeRequestIface GtkSizeRequestMode GtkRequestedSize -gtk_size_request_get_height -gtk_size_request_get_width -gtk_size_request_get_height_for_width -gtk_size_request_get_width_for_height -gtk_size_request_get_request_mode -gtk_size_request_get_size +gtk_widget_get_preferred_height +gtk_widget_get_preferred_width +gtk_widget_get_preferred_height_for_width +gtk_widget_get_preferred_width_for_height +gtk_widget_get_request_mode +gtk_widget_get_preferred_size gtk_distribute_natural_allocation @@ -6310,7 +6308,7 @@ GTK_IS_SIZE_REQUEST GTK_TYPE_SIZE_REQUEST -gtk_size_request_get_type +gtk_widget_get_type
diff --git a/docs/reference/gtk/gtk3.types b/docs/reference/gtk/gtk3.types index 10a9e2d319..aaad23126e 100644 --- a/docs/reference/gtk/gtk3.types +++ b/docs/reference/gtk/gtk3.types @@ -131,7 +131,6 @@ gtk_separator_menu_item_get_type gtk_separator_tool_item_get_type gtk_settings_get_type gtk_size_group_get_type -gtk_size_request_get_type gtk_socket_get_type gtk_spin_button_get_type gtk_spinner_get_type diff --git a/docs/reference/gtk/tmpl/gtkcontainer.sgml b/docs/reference/gtk/tmpl/gtkcontainer.sgml index ea2ff059f0..3d0f2fb9e3 100644 --- a/docs/reference/gtk/tmpl/gtkcontainer.sgml +++ b/docs/reference/gtk/tmpl/gtkcontainer.sgml @@ -58,7 +58,7 @@ of their children. The size requisition phase of the widget layout process operates top-down. It starts at a top-level widget, typically a #GtkWindow. The top-level widget -asks its child for its size requisition by calling gtk_size_request_get_size(). +asks its child for its size requisition by calling gtk_size_request_get_preferred_size(). To determine its requisition, the child asks its own children for their requisitions and so on. Finally, the top-level widget will get a requisition back from its child. diff --git a/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml b/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml index 4f338198a5..f50edf41a4 100644 --- a/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml +++ b/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml @@ -37,7 +37,7 @@ The #GtkFileChooserButton supports the #GtkFileChooserAction